<?php

require_once "../src/verify.php";
require_once "../src/utils.php";

use PHPUnit\Framework\TestCase;
use pUtils\verify;

class verifyTest extends TestCase
{
    public function testIsNull()
    {
        $this->assertTrue(verify::isNull("")::exec());
        $this->assertTrue(verify::isNull()::exec());
        $this->assertTrue(verify::isNull(null)::exec());

        $this->assertFalse(verify::isNull(false)::exec());
        $this->assertFalse(verify::isNull(0)::exec());
        $this->assertFalse(verify::isNull("0")::exec());
    }

    public function testIsDate()
    {
        $this->assertTrue(verify::isNotNull("2021-10-11")::isDate()::exec());
        $this->assertTrue(verify::isNotNull(["2021-10-11", "2021-11-30"])::isDate()::exec());
        $this->assertTrue(verify::isDate(null, ["2021-10-11", "2021-11-30"])::exec());
        $this->assertTrue(verify::isDate(["Y-m-d", "Y/m/d"], ["2021-10-11", "2021-11-30"])::exec());
        $this->assertTrue(verify::isNotNull(["2021-10-11 18:52:13", "25:12:11"])::isDate(["Y-m-d H:i:s", "Y/m/d", "H:i:s"])::exec());

        $this->assertFalse(verify::isNotNull(["2021-10-11"])::isDate(["H:i:s"])::exec());
        $this->assertFalse(verify::isNotNull("2021-02-31")::isDate()::exec());
    }

    public function testBetween()
    {
        $this->assertTrue(verify::between(20, 10, 15)::exec());
        $this->assertTrue(verify::between("20", "10", "15")::exec());
        $this->assertTrue(verify::isInt(5)::between(0, 10)::exec());
        $this->assertTrue(verify::isDate(null, "2021-10-05")::between("2021-10-05", "2021-10-06")::exec());
        $this->assertTrue(verify::isDate(null, "2021-10-05 08:00")::between("2021-10-05 07:00", "2021-10-05 08:00")::exec());

        $this->assertFalse(verify::isNotNull("2021-02-31")::between("2021-02-20", "2021-02-30")::exec());
    }

    public function testLen()
    {
        $this->assertTrue(verify::len("abc", 5)::exec());
        $this->assertTrue(verify::len("abcde", 5)::exec());
        $this->assertTrue(verify::len(200, 200)::exec());


        $this->assertFalse(verify::len("abcdef", 5)::exec());
        $this->assertFalse(verify::len(200, 199)::exec());
    }

    public function testLessAndMore()
    {
        $this->assertTrue(verify::less("10", 9.99)::exec());
        $this->assertTrue(verify::more("10", 10.1)::exec());

        $this->assertFalse(verify::less("10", 10)::exec());
        $this->assertFalse(verify::more("10", 10)::exec());
    }

}
